;
var _pageUrl = "/htmlWeb/article/list";
var curPage = 1, total = 0, pageSize = 10, totalPage = 0; //当前页码,总记录数，每页显示数，总页数
function getParam() {
    return {curPage: curPage <= 1 ? 1 : curPage, pageSize: pageSize}
}
function detailData(index) {
    gotoHtml(index, 2);
}
function editData(index) {
    gotoHtml(index, 1);
}
function gotoHtml(index, type) {
    $.ajaxSetup({cache: false});
    $(".mainDiv").load('htmlWeb/systemArticleNewHtml', '', function () {
        $("#id").val(index);
        $("#opType").val(type);
        $.getScript("../../by-webhtml/assets/js/system/system_articleNew.js");
    });
}
function init() {
    $("#add").click(function () {
        gotoHtml(null, 0);
    });
}
function initPagerBar() {
    $("#pager").createPage({
        url: _pageUrl,
        ajaxBackFn: function (data) {
            var _gridHtml = '';
            $.each(data.rows, function (index, row) {
                _gridHtml += '<tr>' +
                    '<td><input type="hidden" class="rowid" value=\"' + row.id + '\"><p>' + row.id + '</p></td>' +
                    '<td><p>' + row.positionName + '</p></td>' +
                    '<td><p>' + row.articleTypeName + '</p></td>' +
                    '<td><p>' + row.name + '</p></td>' +
                    '<td><p>' + row.statusName + '</p></td>' +
                    '<td><p>' + row.viewCount + '</p></td>' +
                    '<td><span class="userSpan"><p>' +
                    '<a href="javascript:editData(' + row.id + ')">编辑</a>' +
                    '<a class="ico" href="javascript:detailData(' + row.id + ')">详情</a>' +
                    '</p></span></td></tr>';
            });
            $("#articleGrid tr:not(:first)").html("");
            $('#articleGrid').append(_gridHtml);
        }
    });
}
$(function () {
    init();
    initPagerBar();
});